package com.signway.harmony_demo.slice;

import com.signway.harmony_demo.ResourceTable;
import com.signway.harmony_demo.slice.base.BaseAbilitySlice;
import com.signway.harmony_demo.utils.CommonData;
import com.signway.harmony_demo.utils.LogUtil;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

public class MainAbilitySlice extends BaseAbilitySlice {
    public static final String TAG = CommonData.TAG + MainAbilitySlice.class.getSimpleName();

    @Override
    public void onStart(Intent intent) {
        LogUtil.info(TAG, "onStart");
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        initView();
    }

    public void initView() {
        findComponentById(ResourceTable.Id_math_game).setClickedListener(new ButtonClick());
        findComponentById(ResourceTable.Id_picture_game).setClickedListener(new ButtonClick());
    }

    private class ButtonClick implements Component.ClickedListener {
        @Override
        public void onClick(Component component) {
            int btnId = component.getId();
            switch (btnId) {
                case ResourceTable.Id_math_game: {
                    LogUtil.info(TAG, "clock math game");
                    MathGameAbilitySlice.startAbilitySlice();
                } break;
                case ResourceTable.Id_picture_game: {
                    LogUtil.info(TAG, "clock picture game");
                } break;
                default: {
                    LogUtil.info(TAG, "clock default");
                } break;
            }
        }
    }
}
